package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Morpeko
 * @description 针对表【setmeal_dish(套餐果蔬关系)】的数据库操作Mapper
 * @createDate 2024-08-08 14:47:22
 * @Entity com.sky.SetmealDish
 */
@Mapper
public interface SetmealDishMapper {

    /**
     * 查询果蔬是否有套餐关联
     *
     * @param dishIds
     * @return
     */
    SetmealDish selectByDishIds(List<Long> dishIds);

    /**
     * 查询套餐是否有果蔬关联
     *
     * @param setmealId
     * @return
     */
    //@Select("SELECT id, setmeal_id, dish_id, name, price, copies FROM setmeal_dish WHERE setmeal_id = #{setmealId}")
    List<SetmealDish> selectDisableSetmealDish(Long setmealId);

    /**
     * 根据套餐id查询套餐关联的果蔬状态
     * @param setmealId
     * @return
     */
    List<SetmealDish> selectDisableDish(Long setmealId);

    /**
     * 根据套餐id查询套餐关联的果蔬
     * @param setmealId
     * @return
     */
    @Select("select id, setmeal_id, dish_id, name, price, copies from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> selectSetmealDishBySetmealId(Long setmealId);

    /**
     * 插入套餐果蔬关联信息
     * @param setmealDishes
     */
    void insertSetmealDishes(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id删除套餐果蔬关联信息
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteSetmealDishBySetmealId(Long setmealId);
}




